
<div class="row">
  <?php
  $start_num = ($page->current > 3) ? ($page->current - 3) : 1;
  $total_num = (($start_num + 9) <= $page->total_pages) ? (($start_num + 9) ) : $page->total_pages;
  $end_num = $page->current + 3;
  if ($end_num - $start_num < 6) {
    $end_num += 6 - ($end_num - $start_num);
  }
  $end_num = $total_num > $end_num ? $end_num : $total_num;
  $params = $_GET;
  $params['page'] = $page->before;
  unset($params['_url']);
  $url = isset($url) && !empty($url) ? $url : $this->router->getRewriteUri();
  ?>
  <div class="col-sm-4">
    共 <?= $page->total_pages ?> 页 共 <?= $page->total_items ?> 条
  </div>
  <div class="col-sm-8">
    <nav>
    <ul class="pagination justify-content-center">
      <li class="page-item"><a class="page-link" href="<?= $this->url->get($url, $params) ?>"> <span aria-hidden="true">&laquo;</span> </a></li>
      <?php
      for ($i = $start_num; $i <= $end_num; $i++) {
        $params['page'] = $i;
        $fullurl = $this->url->get($url, $params);
        if ($i == $page->current) {
          echo '<li class="page-item active"><span class="page-link">'.$i.'<span class="sr-only">(current)</span></span></li>';
        } else {
          echo '<li class="page-item"><a class="page-link" href="'.$fullurl.'">'.$i.'</a></li>';
        }
      }

      $params['page'] = $page->next;
      ?>
      <li class="page-item"><a class="page-link" href="<?= $this->url->get($url, $params) ?>"> <span aria-hidden="true">&raquo;</span> </a></li>
    </ul>
    </nav>
  </div>
</div>
